home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD ROM Paradise Collection 4
/
CD ROM Paradise Collection 4 1995 Nov.iso
/
science
/
sm32a.zip
/
SYMBMATH.H34
< prev
next >
Wrap
Text File
|
1993-11-07
|
2KB
|
51 lines
4.2.2 Comparising and testing numbers
You can compare two numbers by relational operators
a > b
a < b
a <= b
a >= b
a <> b
a == b
Example 4.2.5.
IN: 2 > 1, 2 < 1
OUT: 1, 0
You also can compare two numbers, even complex numbers z1 and z2 by
islarger(z1, z2)
isless(z1, z2)
issame(z1, z2)
Example 4.2.6.
compare 1+i and 1-i.
IN: islarger(1+i, 1-i) # is 1+i larger than 1-i ?
OUT: 1 # yes, 1+i > 1-i
You can compare squre of a variable a^2 > 0 if you know the
property of the variable.
Example 4.2.7.
IN: assume(a > 0)
IN: a^2 > 0, 1/a > 0
OUT: 1, 1
You can test if x is even, odd, integer, real, number or list by
the is* functions:
iseven(x)
isodd(x)
isinteger(x)
isreal(x)
isnumber(x)
islist(x)
isfree(y,x)
islarger(a,b)
isless(a,b)
issame(a,b)
Example:
IN: iseven(2) # is 2 even ?
OUT: 1 # yes
Note that comparison by the is* functions return either 1 if it is
true or 0 otherwise, but comparison by relational operators gives 1 if it
is true, 0 if it is fault, or left unevaluated otherwise.